#!/usr/bin/python

# import MySQL module
import MySQLdb

# connect
db = MySQLdb.connect(host="localhost", user="matteo", passwd="test", db="bayesfortest")

# create a cursor
cursor = db.cursor()

# execute SQL statement
cursor.execute("SELECT * FROM words")

# get the resultset as a tuple
result = cursor.fetchall()

# iterate through resultset
for record in result:
    s = ""
    for i in range(7):
        s+= (str(record[i]) + " ")
    print s
